
import { addTag, getClassify, getPosterList, getTag } from '@/services';
import { ClassifyList, PosterList, TagList } from '@/utils/poster';
import { Effect, Reducer } from 'umi';
export interface IndexModelState {
    name: string;
    PosterList: Array<PosterList>,
    contentLen: number,
    
    getClassify: Array<ClassifyList>
}
export interface IndexModelType {
    namespace: 'poster';
    state: IndexModelState;
    effects: {
        getPosterList: Effect;
       
        getClassify: Effect;
    };
    reducers: {
        save: Reducer<IndexModelState>;
    };
}
const IndexModel: IndexModelType = {
    namespace: 'poster',
    state: {
        name: '',
        PosterList: [],
        contentLen: 0,
       
        getClassify: []
    },

    effects: {
        //获取海报列表
        *getPosterList({ payload }, { call, put }) {
            let result = yield call(getPosterList, payload.params);
            yield put({
                type: 'save',
                payload: {
                    PosterList: result.data,
                    contentLen: result.data[1]
                }
            })
        },
        //获取分类
        *getClassify({ payload }, { call, put }) {
            let result = yield call(getClassify);
            yield put({
                type: 'save',
                payload: {
                    getClassify: result.data
                }
            })
        },
    },
    reducers: {
        save(state, action) {
            return {
                ...state,
                ...action.payload,
            };
        },
    },

};

export default IndexModel;